Racking and handling time loans is considered one of the most unpleasant parts when working with time
series data.
If you have time serious data with daytime information first of all you never know which time zones.
The daytime information is referring to and therefore many users choose to work with the Coordinated
Universal Time or short UTC but as currently the international standard and among others the United
Kingdom Portugal and Iceland are located in the UTC time zone.
So let's have a look at an example.
And we import pandas and then we import historical stock prices for General Electric.
Let's have a look here.
So here we are on the left hand side a daytime index and we have actually time increments of 30 minutes
and we actually open high low close and volume data so let's have a more detailed look here.
And uh we uh.
Salmon the first uh 30 timestamps.
So actually here we are starting at nine thirty eight uh 10 a.m. Then we have for the next period from
10 a.m. to 10 30 and so on.
And actually the very last the timestamp on a day is actually here from 15 30 to 4:00 p.m. So these
are actually the irregular trading hours on the New York Stock Exchanges.
So this daytime information is they are actually based on New York time are actually Eastern time and
actually New York Time or Eastern time is four hours behind UTC and we can also get some meta information
here so that's a daytime index and let's have a closer look on the index and apparently here we cannot
see any information on the time zone and we can explicitly get information on the time so nervous.
The index method.
T said and obviously here we have no information on the time so and so we have actually no time zone
addressed here to our data frame or to our daytime index.
So to say our data frame and our daytime index here time less and that's actually our first step here
we have to localize our daytime index and we can actually do this with the math that tease that localize
and by doing so we actually set as safe a time zone on our daytime index.
And for example we can choose a UTC.
So we know that here our daytime index is based on is done on New York time.
But first of all we can for example localize that to UTC
and still be a fear the day and the time and then we have fear and additional information plus the zero
hours and minutes.
And actually once we have localized our daytime index then here we can see the difference the time offset
to the UTC time.
And if we localize what it takes to UTC then of course the time difference offset is zero.
So now let's localize our daytime index to a New York time and we can do this by passing America New
York
now and still of course we have the same daytime information.
So the twenty ninth of July and the first time the embassy or 10:00 but here we have the additional
information that we are four hours behind the UTC time.
So that's the New York.
Eastern time and do we have 10 a.m. and the corresponding UTC time is actually at 2:00 p.m. or 14 p.m..
All right and actually to save our time zone information we have uh 2 0 0 0 right here.
Our data frame.
So we have to reassign it here to the variability.
So here we have on the left hand side the localized daytime index and in the next video we will see
how to convert a localized the daytime index to another time slow and soft like cyber to L.A..
So for example we can get to the L.A. Time corresponding to the New York time.
So thanks for watching and I'll see you also on the next video.
By.